import React from "react";
import {
  BrowserRouter as Router,
  Redirect,
  Route,
  Switch,
} from "react-router-dom";
import Login from "./views/login/Login";
import AppLayout from "./layout/AppLayout";
import { withUserStore } from "./store/user";

function App({ userStore: { isLogin } }) {
  return (
    <Router>
      <Switch>
        <Route path="/login" component={Login} />
        {/* 路径为‘/’，有路由拦截 */}
        <Route
          path="/"
          render={() => (isLogin ? <AppLayout /> : <Redirect to="/login" />)}
        />
      </Switch>
    </Router>
  );
}

export default withUserStore(App);

// https://www.axureshop.com/ys/2206290
